WebTextEditor provides a property to add custom toolbar during InitializeToolBar server side event.
In this topic, you will learn how to add custom toolbar.
To custom toolbar during Server Side event
- Implement InitializeToolBar server side event in the WebTextEditor. Here is the snippet to add the custom toolbar with some commands to the WebTextEditor:
C#
Copy Codeprotected void WebTextEditor1_InitializeToolBar(object sender, ISNet.WebUI.WebTextEditor.WebTextEditorToolBarArgs e) { WebTextEditorToolBar tbCustom = new WebTextEditorToolBar(); tbCustom.Name = "tbCustom"; WebTextEditorToolCommand cmdCustom1 = new WebTextEditorToolCommand(); cmdCustom1.Name = "cmdCustom1"; cmdCustom1.Text = "Custom Button 1"; WebTextEditorToolCommand cmdCustom2 = new WebTextEditorToolCommand(); cmdCustom2.Name = "cmdCustom2"; cmdCustom2.Text = "Custom Button 2"; tbCustom.ToolCommands.Add(cmdCustom1); tbCustom.ToolCommands.Add(cmdCustom2); WebTextEditor1.ToolBar.Add(tbCustom); }
- Implement onToolBarClick client side event to display a message when the newly created command in the custom toolbar is clicked. Here is the snippet:
Javascript
Copy Codefunction WebTextEditor1_OnToolBarClick(controlId, command, commandSection) { var rte = ISGetObject(controlId); switch (command.Name) { case "cmdCustom1": alert("Custom button 1 clicked"); break; case "cmdCustom2": alert("Custom button 2 clicked"); break; } }